%{

#include "../include/ast.h"
#include <string>
#include "c0parser.hpp"

%}

INTERGER   [0-9]
NOTE_S     \/\/(.)*\n
NOTE_M     \/\*(.|\n)*?\*\/
IDENTIFIER [_a-zA-Z][_a-zA-Z0-9]*

%%

"("                         {return '(';}
")"                         {return ')';}
"{"                         {return '{';}
"}"                         {return '}';}
","                         {return ',';}
";"                         {return ';';}
"+"                         {return '+';}
"-"                         {return '-';}
"*"                         {return '*';}
"/"                         {return '/';}
"="                         {return '=';}

"int"                       {return INT;}
"else"                      {return ELSE;}
"if"                        {return IF;}
"return"                    {return RETURN;}
"void"                      {return VOID;}
"while"                     {return WHILE;}

" "                         {  /*no action and no return*/ }
"\t"                        {  /*no action and no return*/ }
"\n"                        {  /*no action and no return*/ }
{NOTE_S}*                   {  /*no action and no return*/ }
{NOTE_M}*                   {  /*no action and no return*/ }

{INTERGER}+                 {yylval.number = atoi(yytext); return NUMBER;}
{IDENTIFIER}                {strcpy(yylval.strValue, yytext); return ID;}

%%

int yywrap(){
    return 1;
}